public class SimpleDotCom {
    int[] locationCells;
    int numOfHits = 0;

    public void setLocationCells(int[] locs) {
        locationCells = locs;
    }

    public String checkYourself(String stringGuess) {
        int guess = Integer.parseInt(stringGuess); // 将字符串转换为整数
        String result = "miss"; // 创建出保存返回结果的变量，以miss作为默认值

        for (int cell : locationCells) { // 以循环遍历格子
            if (guess == cell) { // 比较格子与猜测值
                result = "hit"; // 命中
                numOfHits++;
                break; // 退出循环但需判断是否击沉
            }
        }
        if (numOfHits == locationCells.length) {
            result = "kill";
        }
        System.out.println(result);
        return result;
    }
}
